package main

import (
	"encoding/json"
	"fmt"
)

func main() {
	s := &StudentA{100, "张三"}
	bytes, err := json.Marshal(s)
	if err != nil {
		fmt.Println("marshal json error.", err)
		return
	}
	content := string(bytes)
	fmt.Println("json is :", content)
	var stu StudentA
	json.Unmarshal(bytes, &stu)
	fmt.Println("stu=", stu)
}

type StudentA struct {
	Id int	`json:"id"`
	Name string `json:"name"`
}
